package com.brush.web.controller;

import com.brush.app.domain.req.project.ProjectReq;
import com.brush.app.domain.resp.project.ProjectResp;
import com.brush.app.service.AppProjectService;
import com.brush.common.core.controller.BaseController;
import com.brush.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * ClassName: AdminProjectController
 * Package: com.brush.web.controller
 * Description:
 *
 * @Author luo
 * @Create 2024/11/20 20:13
 * @Version 1.0
 */
@Api(tags = "后台-项目管理")
@RestController
@RequestMapping(value = "/admin/project")
public class AdminProjectController extends BaseController {

    @Autowired
    private AppProjectService appProjectService;


    @PreAuthorize("@ss.hasPermi('app:project:list')")
    @ApiOperation(value = "项目分页查询")
    @GetMapping(value = "/list")
    public R<PageInfo<ProjectResp>> pagination(ProjectReq req) {
        PageInfo<ProjectResp> pageInfo = appProjectService.pagination(req);
        return R.ok(pageInfo);
    }

    @ApiOperation(value = "新增项目")
    @PreAuthorize("@ss.hasPermi('app:project:add')")
    @PostMapping
    public R add(@RequestBody @Valid ProjectReq req) {
        boolean result = this.appProjectService.add(req);
        return super.isSuccess(result);
    }


}
